using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Diagnostics;
/// 12.11.2008 - schimbare layout
///              adauare proprietate DataBindings             
namespace RelationTextBox
{
    [ComplexBindingProperties("DataSource", "DataMember")]
    [DefaultBindingProperty("Text")]
    public partial class RelationComboBox : UserControl
    {
        public event EventHandler ButtonClick;
        public event EventHandler MyTextChanged;
        public RelationComboBox()
        {
            InitializeComponent();
            this.cxBRelation.MaxLength = 32767;
            //this.btnRelation.Location = new Point(0,2);

        }
        public Boolean HasButtonHandler()
        {
            return ButtonClick != null;
        }

        public Boolean IsHandler(EventHandler hand)
        {
            return ButtonClick == hand;
        }

        public void ClearHandler()
        {
            ButtonClick = null;
        }

        [Browsable(true)]
        [Description("Alinierea pe orizontala din controlul de editare")]
        public HorizontalAlignment TextAlign
        {
            get
            {
                return HorizontalAlignment.Left;
            }
        }
        [Browsable(true)]
        [Description("Culoarea fondului")]
        public override Color  BackColor
        {
	          get 
	        { 
		         return base.BackColor;
	        }
	          set 
	        { 
		        base.BackColor = value;
                this.cxBRelation.BackColor = value;
	        }
        }

        [Browsable(true)]
        [Description("Valoarea din camp.")]
        public override String Text
        {
            get
            {
                return this.cxBRelation.Text;
            }
            set
            {
                cxBRelation.Text = value;
                //MyTace("RelationTextBox.Text = " + value.ToString());
            }
        }
        [Browsable(true)]
        [DefaultValue(0)]
        [Description("Numarul maxim de caractere acceptate.")]
        public int MaxLength
        {
            get
            {
                return this.cxBRelation.MaxLength;
            }
            set
            {
                cxBRelation.MaxLength = value;
            }
        }
        [Browsable(true)]
        [Description("Marginea la edit.")]
        [DefaultValue(BorderStyle.Fixed3D)]
        new public BorderStyle BorderStyle
        {
            get
            {
                return BorderStyle.None;
            }
            
        }
        
        [Description("Indica spre sursa de date a controlului.")]
        [RefreshProperties(RefreshProperties.Repaint)]
        new public ControlBindingsCollection DataBindings
        {
            get
            {
                return cxBRelation.DataBindings;
            }
        }

        private void btnRelation_Click(object sender, EventArgs e)
        {
            EventHandler temp = ButtonClick;
            if (temp != null)
                temp(this, e);
        }

        private void txBRelation_TextChanged(object sender, EventArgs e)
        {
            EventHandler temp = MyTextChanged;
            if (temp != null)
                temp(this, e);
        }
        private Object _DataSource = null;
        public Object DataSource 
        { 
            get{return _DataSource;}
            set { _DataSource = value; }
        }
        private string _DataMember = null;
        public string DataMember
        {
            get { return _DataMember; }
            set { _DataMember = value; }
        }

     }
}